
import axios from 'axios'
import notification from 'ant-design-vue/es/notification'
// 创建 axios 实例
const service = axios.create({
    timeout: 10000, // 请求超时时间
    headers: {

    },
})
// 请求拦截器
// service.interceptors.request.use(config => {
//     const token = Vue.ls.get(ACCESS_TOKEN)
//     if (token) {
//         config.headers['Authorization'] = token
//     }
//     return config
// })

//响应拦截器
service.interceptors.response.use((response) => {
    if (response.data.code === 200) {
        return response.data
    } else if (response.data.code === 400) {
        notification.error({
            message: '错误',
            description: response.data.msg,
            duration: 5
        })
        return
    } else if (response.data.code === 500 || response.data.code === 300 || response.data.code === 302) {
        notification.error({
            message: '错误',
            description: response.data.msg,
            duration: 5
        })
        return
    }
    else {
        return response.data
    }
})

export {
    service as axios,
}